<template>
  <view class="box">
    <view class="wx-tou">
      <view class="tou top" :style="'padding-top:' + statusBarHeight1 + 'px'">
        <image
          @click="back"
          class="image1"
          src="https://pic.bangbangtongcheng.com/static/fanhui_bai.png"
        />认证资料
        <p
          @click="amend()"
          v-if="
            userInfo.isShop == 1 ||
            userInfo.enterpriseRecruitmentStatus == 1 ||
            userInfo.personalRecruitmentStatus == 1
          "
        >
          修改
        </p>
      </view>
    </view>
    <view :style="'padding-top:' + (statusBarHeight1 + 60) + 'px'"></view>
    <view style="padding-left: 30rpx">
      <!-- <view class="title" style="display: flex;align-items: center;">
				<span>认证资料</span>
				<image @click="amend()" v-if="userInfo.isShop==1 || userInfo.enterpriseRecruitmentStatus==1 || userInfo.personalRecruitmentStatus==1" style="width: 38rpx;margin-left: 20rpx;"
					src="https://pic.bangbangtongcheng.com/9167938d4dcd4ba982178b9355c399fb" mode="widthFix">
				</image>
			</view> -->
      <view class="" v-if="userInfo.businessType == 1">
        <template v-if="userInfo.isShop == 1">
          <view class="merchanTxt">
            <span class="merchan">公司名称：</span>
            <span>{{ merchantMessage.shopName }}</span>
          </view>
          <view
            class="merchanTxt"
            v-if="
              merchantMessage.mainStoreShopName != '' && merchantMessage.mainStoreShopName
            "
          >
            <span class="merchan">连锁总店：</span>
            <span>{{ merchantMessage.mainStoreShopName }}</span>
          </view>
          <view class="merchanTxt">
            <span class="merchan">门店类型：</span>
            <span>{{ merchantMessage.shopType == 1 ? "店铺" : "楼盘" }}</span>
          </view>
          <view class="merchanTxt">
            <span class="merchan">办公区域：</span>
            <span>{{ merchantMessage.shopArea }}</span>
          </view>
          <view class="merchanTxt">
            <span class="merchan">办公地址：</span>
            <span>{{ merchantMessage.shopAddress }}</span>
          </view>
          <view class="merchanTxt">
            <span class="merchan">法人姓名：</span>
            <span>{{ merchantMessage.contacts }}</span>
          </view>
          <view class="merchanTxt">
            <span class="merchan">门店联系电话：</span>
            <span>{{ merchantMessage.shopPhone }}</span>
          </view>
          <view class="merchanTxt">
            <span class="merchan">联系人手机号：</span>
            <span>{{ merchantMessage.contactsPhone }}</span>
          </view>
          <view class="merchanImg" style="margin-top: 28rpx">
            <view class="merchanImgTxt"> 门店封面图片 </view>
            <image class="imgs" :src="merchantMessage.image" mode="heightFix" />
          </view>
          <view class="merchanImg">
            <view class="merchanImgTxt"> 营业执照 </view>
            <image class="imgs" :src="merchantMessage.businessLicense" mode="heightFix" />
          </view>
          <view
            class="merchanImg"
            v-if="
              merchantMessage.idCardUp != 'undefined' && merchantMessage.idCardUp != ''
            "
          >
            <view class="merchanImgTxt"> 法人身份证（人像面） </view>
            <image class="imgs" :src="merchantMessage.idCardUp" mode="widthFix" />
          </view>
          <view
            class="merchanImg"
            v-if="
              merchantMessage.idCardDown != 'undefined' &&
              merchantMessage.idCardDown != ''
            "
          >
            <view class="merchanImgTxt"> 法人身份证（国徽面） </view>
            <image class="imgs" :src="merchantMessage.idCardDown" mode="widthFix" />
          </view>
          <view class="merchanImg">
            <view class="merchanImgTxt"> 个人身份证（人像面） </view>
            <image class="imgs" :src="merchantMessage.cardUp" mode="widthFix" />
          </view>
          <view class="merchanImg">
            <view class="merchanImgTxt"> 个人身份证（国徽面） </view>
            <image class="imgs" :src="merchantMessage.cardDown" mode="widthFix" />
          </view>
        </template>
        <template v-else-if="userInfo.isShop == 0 && userInfo.isAgent == 1">
          <view class="merchanTxt">
            <span class="merchan">姓名：</span>
            <span>{{ merchantMessage.userName }}</span>
          </view>
          <view class="merchanTxt">
            <span class="merchan">联系方式：</span>
            <span>{{ merchantMessage.phone }}</span>
          </view>
          <view class="merchanTxt">
            <span class="merchan">所属门店：</span>
            <span>{{ merchantMessage.shopName }}</span>
          </view>
          <view class="merchanImg">
            <view class="merchanImgTxt"> 身份证（人像面） </view>
            <image class="imgs" :src="merchantMessage.idCardUp" mode="widthFix" />
          </view>
          <view class="merchanImg">
            <view class="merchanImgTxt"> 身份证（国徽面） </view>
            <image class="imgs" :src="merchantMessage.idCardDown" mode="widthFix" />
          </view>
        </template>
      </view>
      <view class="" v-else-if="userInfo.businessType == 2">
        <template v-if="userInfo.isShop == 1">
          <view class="merchanTxt">
            <span class="merchan">公司名称：</span>
            <span>{{ merchantMessage.storeName }}</span>
          </view>
          <view class="merchanTxt">
            <span class="merchan">门店类型：</span>
            <span>{{
              merchantMessage.storeType == 1
                ? "4S店"
                : merchantMessage.storeType == 2
                ? "汽贸店"
                : merchantMessage.storeType == 3
                ? "美容装饰"
                : "维修保养"
            }}</span>
          </view>
          <view class="merchanTxt">
            <span class="merchan">办公区域：</span>
            <span>{{ merchantMessage.officeArea }}</span>
          </view>
          <view class="merchanTxt">
            <span class="merchan">办公地址：</span>
            <span>{{ merchantMessage.officeAddress }}</span>
          </view>
          <view class="merchanTxt">
            <span class="merchan">门店联系电话：</span>
            <span>{{ merchantMessage.storeContactNumber }}</span>
          </view>
          <view class="merchanTxt">
            <span class="merchan">法人姓名：</span>
            <span>{{ merchantMessage.legalName }}</span>
          </view>
          <view class="merchanTxt">
            <span class="merchan">联系人手机号：</span>
            <span>{{ merchantMessage.contactPhoneNumber }}</span>
          </view>
          <view class="merchanTxt">
            <span class="merchan">门店介绍：</span>
            <span class="huanhang">{{ merchantMessage.storeIntroduction }}</span>
          </view>
          <view class="merchanImg" style="margin-top: 28rpx">
            <view class="merchanImgTxt"> 门店封面图片 </view>
            <image class="imgs" :src="merchantMessage.storeCoverImage" mode="heightFix" />
          </view>
          <view class="merchanImg">
            <view class="merchanImgTxt"> 营业执照 </view>
            <image class="imgs" :src="merchantMessage.businessLicense" mode="heightFix" />
          </view>
          <view class="merchanImg">
            <view class="merchanImgTxt"> 法人身份证（人像面） </view>
            <image class="imgs" :src="merchantMessage.legalIdcardJust" mode="widthFix" />
          </view>
          <view class="merchanImg">
            <view class="merchanImgTxt"> 法人身份证（国徽面） </view>
            <image class="imgs" :src="merchantMessage.legalIdcardBack" mode="widthFix" />
          </view>
          <view class="merchanImg">
            <view class="merchanImgTxt"> 个人身份证（人像面） </view>
            <image
              class="imgs"
              :src="merchantMessage.personalIdcardJust"
              mode="widthFix"
            />
          </view>
          <view class="merchanImg">
            <view class="merchanImgTxt"> 个人身份证（国徽面） </view>
            <image
              class="imgs"
              :src="merchantMessage.personalIdcardBack"
              mode="widthFix"
            />
          </view>
        </template>
        <template v-else-if="userInfo.isShop == 0 && userInfo.isAgent == 1">
          <view class="merchanTxt">
            <span class="merchan">姓名：</span>
            <span>{{ merchantMessage.realName }}</span>
          </view>
          <view class="merchanTxt">
            <span class="merchan">联系方式：</span>
            <span>{{ merchantMessage.contactInformation }}</span>
          </view>
          <view class="merchanTxt">
            <span class="merchan">所属门店：</span>
            <span>{{ merchantMessage.storeName }}</span>
          </view>
          <view class="merchanImg">
            <view class="merchanImgTxt"> 身份证（人像面） </view>
            <image class="imgs" :src="merchantMessage.idcardJust" mode="widthFix" />
          </view>
          <view class="merchanImg">
            <view class="merchanImgTxt"> 身份证（国徽面） </view>
            <image class="imgs" :src="merchantMessage.idcardBack" mode="widthFix" />
          </view>
        </template>
      </view>
      <view
        class=""
        v-else-if="
          (userInfo.businessType == 0 || !this.userInfo.businessType) &&
          userInfo.enterpriseRecruitmentStatus == 1
        "
      >
        <view class="merchanTxt">
          <span class="merchan">企业全称：</span>
          <span>{{ merchantMessage.enterpriseFullName }}</span>
        </view>
        <view class="merchanTxt">
          <span class="merchan">统一社会信用代码：</span>
          <span>{{ merchantMessage.unifiedSocialCreditCode }}</span>
        </view>
        <view class="merchanTxt">
          <span class="merchan">办公区域：</span>
          <span>{{ merchantMessage.officeArea }}</span>
        </view>
        <view class="merchanTxt">
          <span class="merchan">企业地址：</span>
          <span>{{ merchantMessage.officeAddress }}</span>
        </view>
        <view class="merchanTxt" v-if="merchantMessage.companySize">
          <span class="merchan">公司规模：</span>
          <span>{{ merchantMessage.companySize }}</span>
        </view>
        <view class="merchanTxt">
          <span class="merchan">法人姓名：</span>
          <span>{{ merchantMessage.legalPersonName }}</span>
        </view>
        <view class="merchanTxt">
          <span class="merchan">经办人姓名：</span>
          <span>{{ merchantMessage.attentionLine }}</span>
        </view>
        <view class="merchanTxt">
          <span class="merchan">经办人手机号：</span>
          <span>{{ merchantMessage.operatorsTelephone }}</span>
        </view>
        <view class="merchanTxt">
          <span class="merchan">所属行业：</span>
          <span>{{ merchantMessage.affiliationIndustry }}</span>
        </view>
        <view class="merchanImg">
          <view class="merchanImgTxt"> 营业执照 </view>
          <image class="imgs" :src="merchantMessage.businessLicense" mode="heightFix" />
        </view>
        <view
          class="merchanImg"
          v-if="
            merchantMessage.legalPersonIdCardPortrait != 'undefined' &&
            merchantMessage.legalPersonIdCardPortrait != ''
          "
        >
          <view class="merchanImgTxt"> 法人身份证（人像面） </view>
          <image
            class="imgs"
            :src="merchantMessage.legalPersonIdCardPortrait"
            mode="widthFix"
          />
        </view>
        <view
          class="merchanImg"
          v-if="
            merchantMessage.legalPersonIdCardNationalEmblemFace != 'undefined' &&
            merchantMessage.legalPersonIdCardNationalEmblemFace != ''
          "
        >
          <view class="merchanImgTxt"> 法人身份证（国徽面） </view>
          <image
            class="imgs"
            :src="merchantMessage.legalPersonIdCardNationalEmblemFace"
            mode="widthFix"
          />
        </view>
        <view class="merchanImg">
          <view class="merchanImgTxt"> 经办人身份证（人像面） </view>
          <image
            class="imgs"
            :src="merchantMessage.handledByIdCardPortrait"
            mode="widthFix"
          />
        </view>
        <view class="merchanImg">
          <view class="merchanImgTxt"> 经办人身份证（国徽面） </view>
          <image
            class="imgs"
            :src="merchantMessage.handledByIdCardNationalEmblemFace"
            mode="widthFix"
          />
        </view>
      </view>
      <view
        class=""
        v-else-if="
          (userInfo.businessType == 0 || !this.userInfo.businessType) &&
          userInfo.personalRecruitmentStatus == 1
        "
      >
        <view class="merchanTxt">
          <span class="merchan">真实姓名：</span>
          <span>{{ merchantMessage.realName }}</span>
        </view>
        <view class="merchanTxt">
          <span class="merchan">性别：</span>
          <span>{{ merchantMessage.sexualDistinction == 1 ? "男" : "女" }}</span>
        </view>
        <view class="merchanTxt">
          <span class="merchan">出身年月：</span>
          <span>{{ merchantMessage.birthYears }}</span>
        </view>
        <view class="merchanTxt">
          <span class="merchan">身份证号：</span>
          <span>{{ merchantMessage.idNumber }}</span>
        </view>
        <view
          class="merchanImg"
          v-if="
            merchantMessage.personalIdCardPortrait != 'undefined' &&
            merchantMessage.personalIdCardPortrait != ''
          "
        >
          <view class="merchanImgTxt"> 本人身份证（人像面） </view>
          <image
            class="imgs"
            :src="merchantMessage.personalIdCardPortrait"
            mode="widthFix"
          />
        </view>
        <view
          class="merchanImg"
          v-if="
            merchantMessage.personalIdCardNationalEmblemFace != 'undefined' &&
            merchantMessage.personalIdCardNationalEmblemFace != ''
          "
        >
          <view class="merchanImgTxt"> 本人身份证（国徽面） </view>
          <image
            class="imgs"
            :src="merchantMessage.personalIdCardNationalEmblemFace"
            mode="widthFix"
          />
        </view>
      </view>
    </view>
    <uniBall></uniBall>
  </view>
</template>

<script>
import permision from "@/js_sdk/wa-permission/permission.js";
//#ifdef H5
import wxshare from "../utils/index.js";
//#endif
import { mapGetters } from "vuex";
export default {
  components: {},
  data() {
    return {
      imgUrl: this.$imgSrc,
      confirm: false,
      userInfo: uni.getStorageSync("Pduser"),
      phone: "",
      merchantMessage: {},
    };
  },
  computed: {
    ...mapGetters(["statusBarHeight1", "userinfo"]),
  },
  onShow() {
    this.phone = this.userInfo.phone;
    if (this.phone) {
      this.getUserPhone();
    }
    if (this.userInfo.businessType == 1 && this.userInfo.isShop == 1) {
      this.getShopInfo();
    } else if (
      this.userInfo.businessType == 1 &&
      this.userInfo.isShop == 0 &&
      this.userInfo.isAgent == 1
    ) {
      this.getBrokerInfo();
    } else if (this.userInfo.businessType == 2 && this.userInfo.isShop == 1) {
      this.sourceShopInfo();
    } else if (
      this.userInfo.businessType == 2 &&
      this.userInfo.isShop == 0 &&
      this.userInfo.isAgent == 1
    ) {
      this.sourceBrokerInfo();
    } else if (
      (this.userInfo.businessType == 0 || !this.userInfo.businessType) &&
      this.userInfo.enterpriseRecruitmentStatus == 1
    ) {
      this.corporation();
    } else if (
      (this.userInfo.businessType == 0 || !this.userInfo.businessType) &&
      this.userInfo.personalRecruitmentStatus == 1
    ) {
      this.gerencorporation();
    }
  },

  onLoad(options) {
    if (getApp().globalData.confirm) {
      this.confirm = getApp().globalData.confirm;
    }
    /* #ifdef H5 */
    this.jinzhi();
    /* #endif */
  },
  methods: {
    // 房源商家数据
    getShopInfo() {
      this.$myRequest
        .get("/mob/user/getShopInfoDetailByCopy", {
          id: this.userInfo.shopId,
        })
        .then((res) => {
          this.merchantMessage = res.shopInfo;
        });
    },

    // 房源经纪人数据
    getBrokerInfo() {
      this.$myRequest
        .get("/mob/user/getAgentInfoByUserIdIsQuit", {
          userId: this.userInfo.id,
        })
        .then((res) => {
          this.merchantMessage = res.agentInfo;
        });
    },

    // 车源商家数据
    sourceShopInfo() {
      this.$myRequest
        .get("/api/mobile/vehicleOwner/getPersonalDistributorById", {
          userId: this.userInfo.id,
        })
        .then((res) => {
          this.merchantMessage = res.distributorList || {};
        });
    },

    // 车源经纪人数据
    sourceBrokerInfo() {
      this.$myRequest
        .get("/api/mobile/vehicleOwner/getSalesConsultantDetailsById", {
          userId: this.userInfo.id,
        })
        .then((res) => {
          this.merchantMessage = res.salesConsultant;
        });
    },

    // 公司数据
    corporation() {
      this.$myRequest
        .get("/api/mobile/personnelOwner/getEnterpriseCertificationById", {
          userId: this.userInfo.id,
        })
        .then((res) => {
          this.merchantMessage = res.enterpriseCertification;
        });
    },

    // 个人数据
    gerencorporation() {
      this.$myRequest
        .get("/api/mobile/personnelOwner/getPersonalAuthenticationByUserId", {
          userId: this.userInfo.id,
        })
        .then((res) => {
          this.merchantMessage = res.personalCertification;
        });
    },

    amend() {
      if (this.userInfo.businessType == 1) {
        if (this.userInfo.isShop == 1) {
          uni.navigateTo({
            url: "/pages_my/enter_merchant?amend=1",
          });
        } else if (this.userInfo.isShop == 0 && this.userInfo.isAgent == 1) {
          uni.navigateTo({
            url: "/pages_my/enterBroker?amend=1",
          });
        }
      } else if (this.userInfo.businessType == 2) {
        if (this.userInfo.isShop == 1) {
          uni.navigateTo({
            url: "/pages_owner/my/shopCertification",
          });
        } else if (this.userInfo.isShop == 0 && this.userInfo.isAgent == 1) {
          uni.navigateTo({
            url: "/pages_owner/my/certificationBroker",
          });
        }
      } else if (
        (this.userInfo.businessType == 0 || !this.userInfo.businessType) &&
        this.userInfo.enterpriseRecruitmentStatus == 1
      ) {
        uni.navigateTo({
          url: "/pages_recruitMoney/my/shopCertification",
        });
      } else if (
        (this.userInfo.businessType == 0 || !this.userInfo.businessType) &&
        this.userInfo.personalRecruitmentStatus == 1
      ) {
        uni.redirectTo({
          url: "/pages_recruitMoney/my/certificationInformation",
        });
      }
    },
    //离职功能
    dimission() {
      if (this.userInfo.isAgent == 0) {
        uni.showToast({
          title: "您还不是经纪人",
          icon: "error",
          duration: 2000,
        });
        return;
      } else {
        if (this.userInfo.isShop == 1) {
          uni.showToast({
            title: "商家不能主动离职,仅能注销",
            icon: "none",
            duration: 2000,
          });
          return;
        }
        uni.showModal({
          title: "警告",
          content: "确定要主动离职吗？",
          success: (res) => {
            if (res.confirm) {
              console.log("用户点击确定");
              this.$myRequest
                .post("mob/user/autoconfirmResignation", {
                  userId: this.userInfo.id,
                })
                .then((res) => {
                  console.log(res);
                  uni.showToast({
                    title: res.msg,
                    icon: "none",
                  });
                  setTimeout(() => {
                    _this.getUserPhone();
                  }, 1000);
                });
            } else if (res.cancel) {
              console.log("用户点击取消");
            }
          },
        });
      }
    },
    back() {
      uni.navigateBack({
        delta: 1,
      });
    },
    jinzhi() {
      let _this = this;
      let param = window.location.href.split("#")[0];
      uni.request({
        method: "post",
        data: {
          url: param,
        },
        header: {
          "content-type": "application/x-www-form-urlencoded",
        },
        url: "https://www.bangbangtongcheng.com/conven//mob/login/getJsTicket.do",
        success(re) {
          _this.jinzhifx(re.data);
        },
      });
    },
    jinzhifx(data) {
      wxshare.config({
        debug: false, //是否打开调试
        appId: data.appId, // 公众号的唯一标识
        timestamp: data.timestamp, // 生成签名的时间戳
        nonceStr: data.nonce, // ，生成签名的随机串
        signature: data.signature, // 签名
        jsApiList: ["hideMenuItems"],
      });
      // 禁止分享
      wxshare.hideMenuItems({
        // 要隐藏的菜单项，只能隐藏“传播类”和“保护类”按钮，所有menu项见附录3
        menuList: [
          "menuItem:share:appMessage",
          "menuItem:share:timeline",
          "menuItem:share:timeline",
          "menuItem:share:qq",
          "menuItem:favorite",
          "menuItem:share:QZone",
          "menuItem:openWithSafari",
        ],
      });
    },
    getUserPhone() {
      let that = this;
      this.$myRequest
        .get("/mob/login/getUserInfoByPhone", {
          phone: this.phone,
        })
        .then((res) => {
          this.userInfo = res.userInfo;
          uni.setStorageSync("Pduser", res.userInfo);
          that.$store.dispatch("user/login", res.userInfo);
        });
    },
  },
};
</script>

<style lang="less" scoped>
page {
  background-color: #fff;
}
.box {
  background: #fff;
}
.tou {
  position: relative;
  width: 100%;
  // height: 88rpx;
  text-align: center;
  line-height: 88rpx;
  font-size: 36rpx;
  color: #fff;
  background-color: #64b6a8;

  .image1 {
    position: absolute;
    width: 32rpx;
    height: 32rpx;
    // top: 116rpx;
    left: 30rpx;
  }

  .image2 {
    position: absolute;
    width: 56rpx;
    height: 56rpx;
    // top: 104rpx;
    right: 30rpx;
  }

  p {
    position: absolute;
    // top: 90rpx;
    line-height: 45rpx;
    bottom: 21rpx;
    right: 30rpx;
    /* #ifdef MP */
    right: 210rpx;
    /* #endif */
    font-size: 28rpx;
    color: #fff;
  }
}
/* .content { */

/* #ifdef MP */
/* height: calc(100vh - 192rpx); */
/* #endif */
/* #ifdef APP-PLUS || H5 */
/* height: calc(100vh - statusBarHeight1 - 88rpx); */
/* var(--status-bar-height1) */
/* #endif */
.title {
  /* margin-top: 34rpx; */
  font-size: 34rpx;
  color: #64b6a8;
  margin-bottom: 34rpx;
}

.merchanTxt {
  font-size: 30rpx;
  margin-bottom: 12rpx;

  .merchan {
    color: #64b6a8;
  }
}

.merchanImg {
  margin-bottom: 40rpx;

  .merchanImgTxt {
    font-size: 34rpx;
    margin-bottom: 22rpx;
  }

  .imgs {
    width: 690rpx;
    height: 228rpx;
  }
}
/* } */

.flex {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 30rpx 106rpx 30rpx 30rpx;
  border-bottom: 2rpx solid #e0e0e0;
  font-size: 34rpx;
  position: relative;

  .right {
    position: absolute;
    top: 50%;
    right: 49rpx;
    transform: translateY(-50%);
    width: 19rpx;
  }
}

.userHeader {
  width: 100rpx;
  height: 100rpx;
  border-radius: 50%;
}

.image1 {
  position: absolute;
  width: 32rpx;
  height: 32rpx;

  left: 30rpx;
}

.tou {
  position: fixed;
  width: 100%;
  text-align: center;
  line-height: 88rpx;
  font-size: 36rpx;
  color: #fff;
  background-color: #64b6a8;
  z-index: 10;
}

.certifi-data {
  padding: 34rpx 30rpx;

  .certifi-top {
    display: flex;
    align-items: center;

    text {
      margin-right: 48rpx;
      font-size: 34rpx;
      font-weight: 600;
      color: #333333;
    }

    view {
      display: flex;
      align-items: center;
      font-size: 34rpx;
      color: #64b6a8;
    }
  }

  .certifi-content {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;

    view {
      font-size: 28rpx;
      font-weight: 600;
      color: #64b6a8;
      margin: 60rpx 0 25rpx;
    }

    image {
      width: 270rpx;
      height: 270rpx;
    }
  }
}

.huanhang {
  word-break: break-all;
  line-break: anywhere;
}
</style>
